
/**
 *  Test suite: top level, basically the feature you're trying to test.
 *  Batches: a test suite is a set of batches, run in order and sequentially.
 *  Contexts: right underneath batches, this is basically one given functionality. Contexts are run in parallel.
 *  Vows: atomic checks you want to do to validate the functionality. There are 2 special kind of vow, topic and teardown, which are run first and last. Otherwise all vows are run in parallel. Vows can contain nested contexts.
 */

var $ = require;

var path = $('path');
require.paths.unshift(path.join(__dirname, '../..', 'utils'));
var op = $('operand');

var vows = $('vows'),
    assert = $('assert');

vows.describe('test operand').addBatch({

    //one context, may contains 0 or 1 topic or nested context
    'test all operands': {
        topic: op,

        '>': function(){
            assert.isTrue(op['gt'](5, 4));
        },

        '>=': function(){
            assert.isTrue(op['ge'](1, 1));
            assert.isTrue(op['gt'](5, 4));
        },

        '<': function(){
            assert.isTrue(op['lt'](1, 2));
        },

        '<=': function(){
            assert.isTrue(op['le'](1, 1));
            assert.isTrue(op['le'](1, 2));
        },

        '==': function(){
            assert.isTrue(op['eq'](1, 1));
            assert.isFalse(op['eq'](1, 2));
        },

        'like': function(){
            assert.isTrue(op['like']('abc*', 'abcde'));
            assert.isTrue(op['like']('abc*', 'abc'));
            assert.isFalse(op['like']('abc*', 'eabc'));

            assert.isTrue(op['like']('*abc', 'deabc'));
            assert.isTrue(op['like']('*abc', 'abc'));
            assert.isFalse(op['like']('*abc', 'abcd'));

            assert.isTrue(op['like']('*abc*', 'abcde'));
            assert.isTrue(op['like']('*abc*', 'abc'));
            assert.isTrue(op['like']('*abc*', 'eabc'));
        }
    },
}).export(module);